package com.shamoa.springbootredis.factory;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public enum ThreadPoolFactory {

    INSTANCE;

    private final ExecutorService executorService;

    private ThreadPoolFactory() {
        executorService = Executors.newFixedThreadPool(5);
    }

    // 提交任务到线程池
    public Future submitTask(Runnable task) {
        return executorService.submit(task);
    }

    // 关闭线程池
    public void shutdown() {
        executorService.shutdown();
    }


}
